package com.taokatao.cardmee.api.security;

import android.text.TextUtils;

import com.taokatao.cardmee.App;
import com.taokatao.cardmee.C;

/**
 * Created by LY on 2016/8/17.
 */
public class ServiceUrlProvider {
    public static String obtainMoreUrl() {
        if (App.i().getCurrUser() != null) {
            boolean debugMode = App.DEBUG_SERVICE;
            AES aesEncrypt = new AES(debugMode ? "kmozi#%%#$gbtuue" : "kmozi#$%$$ggmukl");

            String urlPart1 = App.DEBUG_SERVICE ?
                    C.http.DEBUG_SERVICE_URL + "wapServer/find/toFindPage.do?mUserId=" :
                    C.http.RELEASE_SERVICE_URL + "wapServer/find/toFindPage.do?mUserId=";
            String url = urlPart1 + aesEncrypt.encrypt(String.valueOf(App.i().getCurrUser().getUuid()));
            return url;
        }
        return "";
    }

    public static boolean isMoreRootUrl(String url) {
        if (!TextUtils.isEmpty(url)) {
            String urlPart1 = App.DEBUG_SERVICE ?
                    C.http.DEBUG_SERVICE_URL + "wapServer/find/toFindPage.do" :
                    C.http.RELEASE_SERVICE_URL + "wapServer/find/toFindPage.do";
            if (url.startsWith(urlPart1)) {
                return true;
            }
        }
        return false;
    }

    public static String obtainCommentUrl(long cardId) {
        if (App.i().getCurrUser() != null) {
            boolean debugMode = App.DEBUG_SERVICE;
            AES aesEncrypt = new AES(debugMode ? "kmozi#%%#$gbtuue" : "kmozi#$%$$ggmukl");

            String encryptUuid = aesEncrypt.encrypt(String.valueOf(App.i().getCurrUser().getUuid()));
            String encryptCardId = aesEncrypt.encrypt(String.valueOf(cardId));
            String url = App.DEBUG_SERVICE ?
                    C.http.DEBUG_SERVICE_URL + "wapServer/comment/toCommentPage.do?cardId=" + encryptCardId + "&userId=" + encryptUuid :
                    C.http.RELEASE_SERVICE_URL + "wapServer/comment/toCommentPage.do?cardId=" + encryptCardId + "&userId=" + encryptUuid;
            return url;
        }
        return "";
    }

    public static String obtainAppShareUrl() {
        String url = App.DEBUG_SERVICE ?
                C.http.DEBUG_SERVICE_URL + "wapServer/member/goMcardSharePage.do" :
                C.http.RELEASE_SERVICE_URL + "wapServer/member/goMcardSharePage.do";
        return url;
    }

    // 分店课程项目详情
    // type 值为1表示卡详情点击，值为2表示预约界面点击
    public static String obtainOrderedCourseDetailsUrl(long courseId, int type) {
        if (App.i().getCurrUser() != null) {
            String uid = String.valueOf(App.i().getCurrUser().getUuid());
            String url = App.DEBUG_SERVICE ?
                    C.http.DEBUG_SERVICE_URL + "wapServer/bussiness/getOrderedCourseDetails.do?courseId=" + courseId + "&uuid=" + uid + "&type=" + type:
                    C.http.RELEASE_SERVICE_URL + "wapServer/bussiness/getOrderedCourseDetails.do?courseId=" + courseId + "&uuid=" + uid+ "&type=" + type;
            return url;
        }
        return "";
    }

    // 通兑卡(消费卡)的预约
    public static String obtainConsumerOrderUrl(long cardId) {
        if (App.i().getCurrUser() != null) {
            String uid = String.valueOf(App.i().getCurrUser().getUuid());
            String url = App.DEBUG_SERVICE ?
                    C.http.DEBUG_SERVICE_URL + "wapServer/bussiness/goConsumerOrder.do?cardId=" + cardId + "&uuid=" + uid :
                    C.http.RELEASE_SERVICE_URL + "wapServer/bussiness/goConsumerOrder.do?cardId=" + cardId + "&uuid=" + uid;
            return url;
        }
        return "";
    }

    // 分店的优惠券
    public static String obtainGoCouponReceiveUrl(Long sid) {
        if (App.i().getCurrUser() != null && sid != null) {
            String uid = String.valueOf(App.i().getCurrUser().getUuid());
            String url = App.DEBUG_SERVICE ?
                    C.http.DEBUG_SERVICE_URL + "wapServer/bussiness/goCouponReceive.do?sid=" + sid + "&uuid=" + uid :
                    C.http.RELEASE_SERVICE_URL + "wapServer/bussiness/goCouponReceive.do?sid=" + sid + "&uuid=" + uid;
            return url;
        }
        return "";
    }

    // 给分店打分
    public static String obtainGoScoreUrl(Long sid) {
        if (App.i().getCurrUser() != null && sid != null) {
            String uid = String.valueOf(App.i().getCurrUser().getUuid());
            String url = App.DEBUG_SERVICE ?
                    C.http.DEBUG_SERVICE_URL + "wapServer/bussiness/goScore.do?sid=" + sid + "&uuid=" + uid :
                    C.http.RELEASE_SERVICE_URL + "wapServer/bussiness/goScore.do?sid=" + sid + "&uuid=" + uid;
            return url;
        }
        return "";
    }

    // 二维码格式：
    // http://wap.taokatao.cn:64559/wapServer/bussiness/downAddSign.do?storeId=1(测试)
    // http://c.flow360.cn:4559/wapServer/bussiness/downAddSign.do?storeId=1(正式)
    // 如果匹配到和上面链接下划线部分一致的url就发出下面的请求
    // 24、被扫二维码格式  [3码合1]
    public static String obtainStoreQRCodeUrl() {
        String url = App.DEBUG_SERVICE ?
                C.http.DEBUG_SERVICE_URL + "wapServer/bussiness/downAddSign.do?storeId=" :
                C.http.RELEASE_SERVICE_URL + "wapServer/bussiness/downAddSign.do?storeId=";
        return url;
    }
}
